// const data = window._selectData;
const { setFuseNum, fuseListSelect, oldFuseSelect } = window._videoFuse;
const $modalTitle = this.pageObj.getApiWidgetByAliasName('fuse_modal_title').widgetObj;
const $table = this.pageObj.getApiWidgetByAliasName('fuse_modal_table');
const $form = this.pageObj.getApiWidgetByAliasName('fuse_modal_form').widgetObj;
const $videoSwiper = this.pageObj.getApiWidgetByAliasName('fuse_modal_video_swiper');
const modals = this.pageObj.getApiWidgetsByClassName('fuse-modal');

console.log('------edit-------')
function editFuseList(data) {
    $modalTitle._option.links.text = '编辑融合视频';
    $modalTitle.render();

    $table.widgetObj.table.checkrows = _.cloneDeep(data.children || []);
    $table.widgetObj.setDataSource([]);

    setFuseNum(data.children?.length || 0);

    $form.setFormData('fuse_modal_form', data);

    $videoSwiper.widgetObj.sullivan.closeAll();
    $videoSwiper.widgetObj.sullivan.addPlayers(data.children || []);

    modals.forEach(v => v.showWidget());

    _videoFuse.canSave = false;
    _videoFuse.fuseListSelect = { ...data, operate: 'edit' };
    _videoFuse.oldFuseSelect = void 0;
}

if (fuseListSelect && fuseListSelect.fuseName) {
    editFuseList(fuseListSelect)
} else if (fuseListSelect.operate === 'add' && _videoFuse.oldFuseSelect) {
    editFuseList(oldFuseSelect)
} else {
    layer.msg('请选择需要修改的分组');
}
